package com.adpter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.common.method.ServerPath;
import com.google.android.imageloader.ImageLoader;
import com.matang.R;
import com.modle.BlackStruct;

public class BlackListAdapter extends BaseAdapter {
	ArrayList<BlackStruct> dataList;
	Context context;

	public BlackListAdapter(ArrayList<BlackStruct> dataList, Context context) {
		super();
		this.context = context;
		this.dataList = dataList;
	}

	@Override
	public int getCount() {
		return dataList.size();
	}

	@Override
	public Object getItem(int position) {
		return dataList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int pos, View view, ViewGroup parent) {
		ViewHolder vh = null;
		if (view == null) {
			view = LayoutInflater.from(context).inflate(
					R.layout.list_item_blacklist, null);
			vh = new ViewHolder();
			vh.nameTv = (TextView) view.findViewById(R.id.name_tv);
			vh.placeTv = (TextView) view.findViewById(R.id.place_tv);
			vh.signTv = (TextView) view.findViewById(R.id.qm_tv);
			vh.thumIv = (ImageView) view.findViewById(R.id.thumb_iv);
			view.setTag(vh);
		} else {
			vh = (ViewHolder) view.getTag();

		}
		BlackStruct bs =dataList.get(pos);
		
	    ImageLoader.get(context).bind(vh.thumIv,ServerPath.SERVER+bs.thumb, null,R.drawable.default_head);
	    vh.nameTv.setText(bs.nickname);
	    vh.placeTv.setText(bs.liveplace);
	    vh.signTv.setText(bs.signature);

		return view;
	}

	class ViewHolder {
		TextView nameTv,placeTv,signTv;
		ImageView thumIv;

	}
}